
//
//  LYSettingView.m
//  SZBank
//
//  Created by LuoYao on 16/7/14.
//  Copyright © 2016年 LuoYao. All rights reserved.
//

#import "LYSettingView.h"
#import "LYSettingDetailView.h"

@interface LYSettingView ()
@property (nonatomic) LYSettingDetailView *abountMeView;/**< 关于我们 */
@property (nonatomic) LYSettingDetailView *systemView;/**< 系统版本 */
@property (nonatomic) LYSettingDetailView *userHelpView;/**< 用户指南 */
@property (nonatomic) LYSettingDetailView *inputTextView;/**< 用户指南 */
@end
@implementation LYSettingView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //背景
        self.backImageView.image = [LocalDataManager getImageWithSourceOfPath:@"用户中心_01"];
        [self addSubview:self.backImageView];
        
        
        //四个按钮
        NSArray *btnTitles = @[@"用户中心_03",@"用户中心_04",@"用户中心_05",@"用户中心_06"];
        for (int i = 0; i < btnTitles.count; i ++) {
            UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, _cKwidth * 0.3, _cKheight * 0.06)];
            btn.center = CGPointMake(self.backImageView.frame.size.width * 0.5, self.backImageView.frame.size.height * 0.10  * i + self.backImageView.frame.size.height * 0.2);
            [btn setBackgroundImage:[LocalDataManager getImageWithSourceOfPath:btnTitles[i]] forState:UIControlStateNormal];
            btn.tag = 1000 + i;
            [btn addTarget:self action:@selector(action_btnClick:) forControlEvents:UIControlEventTouchUpInside];
            
            [self.backImageView addSubview:btn];
        }
        
        //关闭按钮
        UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.backImageView.frame.size.width * 0.95, 30, 40, 40)];
        [closeBtn setBackgroundImage:[LocalDataManager getImageWithSourceOfPath:@"金融资讯_详情关闭"] forState:UIControlStateNormal];
        [closeBtn addTarget:self action:@selector(action_btnClick:) forControlEvents:UIControlEventTouchUpInside];
        closeBtn.tag = 1000 + 4;
        [self.backImageView addSubview:closeBtn];
        
    }
    return self;
}

#pragma mark - 点击事件
- (void)action_btnClick:(UIButton *)sender{
//    //移除其他视图
//    if ([self.superview.subviews.lastObject isKindOfClass:[LYBackView class]]) {
//        [self.superview.subviews.lastObject removeFromSuperview];
//    }

    switch (sender.tag - 1000) {
        case 0:
        {//关于我们
            [self addSubview:self.abountMeView];
        }
            break;
        case 1:
        {//版本信息
            [self addSubview:self.systemView];
        }
            break;
        case 2:
        {//使用指南
            [self addSubview:self.userHelpView];
        }
            break;
        case 3:
        {//用户反馈
            [self addSubview: self.inputTextView];
        }
            break;
            
            
        case 4:
        {
            [self dismissAnimation];
        }
            break;
            
        default:
            break;
    }
}


#pragma mark - getter
- (UIImageView *)backImageView{
    if (!_backImageView) {
        _backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _cKwidth * 0.8, _cKheight * 0.9)];
        _backImageView.center = CGPointMake(self.center.x,_cKheight * 0.6);
        _backImageView.userInteractionEnabled = YES;
    }
    return _backImageView;
}

- (LYSettingDetailView *)abountMeView{
    if (!_abountMeView) {
        _abountMeView = [[LYSettingDetailView alloc] initWithFrame:CGRectMake(0, 0, _cKwidth * 0.8, _cKheight * 0.9) style:LYSettingDetailViewStyleAbountMe title:@"关于我们"];
        _abountMeView.center = CGPointMake(self.center.x,_cKheight * 0.6);
    }
    return _abountMeView;
}

- (LYSettingDetailView *)systemView{
    if (!_systemView) {
        _systemView = [[LYSettingDetailView alloc] initWithFrame:CGRectMake(0, 0, _cKwidth * 0.8, _cKheight * 0.9) style:LYSettingDetailViewStyleSystem title:@"系统版本"];
        _systemView.center = CGPointMake(self.center.x,_cKheight * 0.6);
    }
    return _systemView;
}

- (LYSettingDetailView *)userHelpView{
    if (!_userHelpView) {
        _userHelpView = [[LYSettingDetailView alloc] initWithFrame:CGRectMake(0, 0, _cKwidth * 0.8, _cKheight * 0.9) style:LYSettingDetailViewStyleUser title:@"用户指南"];
        _userHelpView.center = CGPointMake(self.center.x,_cKheight * 0.6);
    }
    return _userHelpView;
}

- (LYSettingDetailView *)inputTextView{
    if (!_inputTextView) {
        _inputTextView = [[LYSettingDetailView alloc] initWithFrame:CGRectMake(0, 0, _cKwidth * 0.8, _cKheight * 0.9) style:LYSettingDetailViewStyleText title:@"意见反馈"];
        _inputTextView.center = CGPointMake(self.center.x,_cKheight * 0.6);
    }
    return _inputTextView;
}
@end
